
export function checkLogin() {
	// 验证是否已经登录过了
	uni.getStorage({
		key: "token",
		success: (token) => {
			uni.request({
				url: "/api/user/info",
				method: "GET",
				header: {
					Authorization: token.data,
				},
				success: (res) => {
					uni.setStorage({
						key: "user",
						data: res.data.data,
					})
					console.log("get user info!")
					uni.switchTab({
						url: "/pages/home/home"
					})
				},
				fail() {
					console.log("get user info fial!")
					uni.redirectTo({
						url: "/pages/index/index"
					})
					uni.clearStorage()
				}
			})
		},
		fail: (res) => {
			console.log("token is not find!")
			uni.redirectTo({
				url: "/pages/index/index"
			})
			uni.clearStorage()
		}
	})
}